package com.qf.controller;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @version v1.0.0
 * @Description:
 * @author: 赵英杰
 * @date: 2022.02.14
 * @since 1.0
 */
//@ControllerAdvice
//@ResponseBody
@RestControllerAdvice
public class MyHandlerException {

    /**
     * @return
     * @ExceptionHandler:指定该方法要处理的异常类型
     */
    @ExceptionHandler({
            ArithmeticException.class
    })
    public String handlerArithmeticException() {
        return "0";
    }

    /**
     * @return
     * @ExceptionHandler:指定该方法要处理的异常类型
     */
    @ExceptionHandler({
            RuntimeException.class
    })
    public String handlerRunTimeException() {
        return "1";
    }

    /**
     * @return
     * @ExceptionHandler:指定该方法要处理的异常类型
     */
    @ExceptionHandler({
            Exception.class
    })
    public String handlerException() {
        return "2";
    }
}
